<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCustomersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customers', function (Blueprint $table) {
            $table->id();
            $table->string('username',50)->nullable()->comment('账号');
            $table->string('truename',50)->nullable()->default('未知')->comment('真实姓名');
            $table->string('password',255)->nullable()->comment('密码');


            $table->string('phone',15)->default('')->comment('手机号码');
            $table->string('nickName')->default('')->comment('小程序昵称');
            $table->string('avatarUrl')->default('')->comment('小程序头像');
            $table->string('country')->default('')->comment('国家');
            $table->string('province')->default('')->comment('省份');
            $table->string('city')->default('')->comment('城市');
            $table->unsignedTinyInteger('programe_gender')->default(0)->comment('性别 0 未知，1男性 ，2女性，');
            $table->string('unionid')->default('')->comment('平台唯一识别');
            $table->string('openid')->default('')->comment('小程序openid');


            $table->char('last_ip',15)->default('')->comment('登录IP');
            $table->unsignedInteger('invite_num')->default(0)->comment('推荐码');

            $table->string('name')->nullable()->comment('姓名');
            $table->string('gender')->nullable()->comment('性别');
            $table->string('nationality')->nullable()->comment('民族');
            $table->string('address')->nullable()->comment('地址');
            $table->string('id_number')->nullable()->comment('身份证号');
            $table->string('issue_place')->nullable()->comment('签发地');
            $table->string('expire_start')->nullable()->comment('有效期开始');
            $table->string('expire_end')->nullable()->comment('有效期结束');

            $table->string('driver_name')->nullable()->comment('驾驶证姓名');
            $table->string('driver_gender')->nullable()->comment('驾驶证性别');
            $table->string('driver_issue_place')->nullable()->comment('驾驶证签发地');
            $table->string('driver_address')->nullable()->comment('驾驶证地址');
            $table->string('driver_id_number')->nullable()->comment('驾驶证身份证号');
            $table->string('driver_car')->nullable()->comment('驾驶证准驾车型');
            $table->string('driver_expire_start')->nullable()->comment('有效期开始');
            $table->string('driver_expire_end')->nullable()->comment('有效期结束');

            $table->tinyInteger('register_source')->default(1)->comment('注册来源：默认1线上2先写');
            $table->integer('source_id')->default(0)->comment('来源id默认总店');

            $table->string('face_url')->nullable()->comment('身份证正面');
            $table->string('back_url')->nullable()->comment('身份证反面');
            $table->string('driver_face_url')->nullable()->comment('驾驶证正面');
            $table->string('driver_back_url')->nullable()->comment('驾驶证反面');

            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customers');
    }
}
